<?php namespace App\Http\Requests;
/**
 * Created by PhpStorm.
 * User: liandne
 * Date: 16/5/28
 * Time: 下午12:01
 */


class SignInRequest extends Request {

	/**
	 * Determine if the user is authorized to make this request.
	 *
	 * @return bool
	 */
	public function authorize()
	{
		return true;
	}

	public function attributes()
	{
		return [
			'unit_login' => '统一登录',
			'username'   => '用户名',
			'email'      => '邮箱',
			'phone'      => '手机号',
			'password'   => '密码',
			'remember'   => '记住密码',
		];
	}

	/**
	 * Get the validation rules that apply to the request.
	 *
	 * @return array
	 */
	public function rules()
	{
		return [
			'unit_login'  => ['required_without_all:username,email,phone', 'regex:/(^[A-aZ-z])|(^[1-9]d*)|(\.)|(\@)|(_)/'],
			'username'    => 'required_without_all:unit_login,email,phone|alpha_dash|min:2|max:20',
			'email'       => 'required_without_all:unit_login,username,phone|email',
			'phone'       => ['required_without_all:unit_login,username,email', 'regex:/1\d{10}/'],
			'password'    => 'required|alpha_dash|min:0',
			'remember'    => 'required|boolean'
		];
	}

}
